
var app = new Vue({
    el: '.box',
    data: {
        z: '',
        p: ''
    },
    methods: {
        logins() {
            if (this.z === '') {
                this.$message({
                    message: '请输入账号...',
                    type: 'warning'
                });
                return false;
            };
            if (this.p === '') {
                this.$message({
                    message: '请输入密码...',
                    type: 'warning'
                });
                return false;
            };
            info({ z: this.z, p: this.p });
        }
    }
});



function info(obj) {
    var loading = app.$loading({
        lock: true,
        text: 'Loading',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
    axios({
        method: "POST",//类型
        baseURL: '../admin/api/index.php',//地址
        data: 'data=' + JSON.stringify({ head: 1000, z: obj.z, p: obj.p })
    }).then(function (res) {
        loading.close();
        if (res.data.code === '200') {
            var d = res.data.data;
            app.$message({
                message: `欢迎${d[0].name}`,
                type: 'success'
            });
            sessionStorage.setItem('token', d[0].token);
            setTimeout(function(){
                window.location.href = './view/index.html';
            },500);
        } else {
            app.$message({
                message: res.data.msg,
                type: 'warning'
            });
        };
    }).catch(function (err) {
        console.log(err);//失败返回错误信息
    });//获取nav
};